﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zip;
using System.IO;

namespace Azure.TableQuery.Core
{
    public class CompressionUtility
    {
        public static void Compress(Stream source, Stream destination, string filename)
        {
            using (ZipFile zip = new ZipFile())
            {
                zip.AddFileFromStream(filename, "", source);
                zip.Save(destination);
            }
        }

        public static void Decompress(Stream source, Stream destination, string filename)
        {

            using (ZipFile zip = ZipFile.Read(source))
            {
                foreach (ZipEntry entry in zip)
                {
                    zip.Extract(filename, destination);
                }
            }
        }
    }
}
